package es.ats.codington.festival.services;


import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import es.ats.codington.festival.daos.ManagerDAO;
import es.ats.codington.festival.domain.Event;
import es.ats.codington.festival.domain.EventSignUp;

import es.ats.codington.festival.exceptions.ServiceException;

import es.ats.codington.festival.interfaces.daos.IEventSignUpDAO;
import es.ats.codington.festival.interfaces.services.IEventSignUpService;

/**
 * 
 * @author Codington_RED
 *
 */
public class EventSignUpService implements IEventSignUpService{

	
	private IEventSignUpDAO eventSignUpDAO;
	
	public EventSignUpService(){
		ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");  
		ManagerDAO daoManager = (ManagerDAO) ctx.getBean("daoManager");
		this.eventSignUpDAO = daoManager.getEventSignUpDAO();
	}
	
	
	/**
	 * A method service that check the events which a visitor are registered in 
	 * @param eventSignUp
	 * @return eventSignUpDAO.checkEventsofVisitor(eventSignUp
	 * @throws ServiceException
	 */
	@Override
	public boolean checkEventsofVisitor(EventSignUp eventSignUp) throws ServiceException {
		
		return eventSignUpDAO.checkEventsofVisitor(eventSignUp);
				
	}

	
	/**
	 * method to unregister of any Event.
	 * @param eventSignUp
	 * @return eventSignUpDAO.unregisterVisitorToEvent(eventSignUp)
	 * @throws ServiceException
	 */
	@Override
	public boolean unregisterVisitorToEvent(EventSignUp eventSignUp) throws ServiceException{
		
		return eventSignUpDAO.unregisterVisitorToEvent(eventSignUp);
		
	}

	
	/**
	 * method to register in a event
	 * @param eventsignup
	 * @return eventSignUpDAO.registerVisitorToEvent(eventsignup)
	 * @throws ServiceException
	 */
	@Override
	public boolean registerVisitorToEvent(EventSignUp eventsignup) throws ServiceException {
		
		return eventSignUpDAO.registerVisitorToEvent(eventsignup);
	
	}

	
	/**
	 * method that show us a list with all event which the visitor are registered in
	 * @param eventSignUp
	 * @return eventSignUpDAO.registeredEvents(eventSignUp)
	 * @throws ServiceException
	 */
	@Override
	public List<Event> registeredEvents(EventSignUp eventSignUp) throws ServiceException {
		
		return eventSignUpDAO.registeredEvents(eventSignUp);
		
	}


}
